/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DEVICES_E2827SX_H
#define DEVICES_E2827SX_H

/* Includes ------------------------------------------------------------------*/
#include "Devices_E2827SX_BaseConfig.h"
#include "usart.h"
/* Exported constants --------------------------------------------------------*/
/* Using Grand unions */
#pragma anon_unions

#define E28_SettingMessageLength 6
#define E28_ReceiveBufferLength 10


/* 2G4 Base Config */
#define E28_PACK_HEAD				E2G4_CMD_HEAD
#define E28_2G4_ADDR        E2G4_DEFAULT_ADDRESS
#define E28_2G4_CHANNEL     E2G4_DEFAULT_CHANNAL
#define E28_UART_INS				E2G4_UART_8N1
#define E28_UART_BAUDRATE		E2G4_UART_115200
#define E28_RF_BPS					E2G4_RF_BPS_10K
#define E28_TXMODE					E2G4_TPN_TXMODE
#define E28_DEVICE_LEV			E2G4_MASTER
#define E28_LBT							E2G4_LBT_DISABLE
#define E28_IO							E2G4_TXD_AUX_PP_RXD_UP
#define E28_TXPOWER					E2G4_27dBm




/* Exported macros -----------------------------------------------------------*/
/* E28 Functions GroundInit */
#define E28_FunctionsGround_Init \
{ \
	&E28_USART_IT_Register, \
	&E28_RF_Setting, \
	&E28_USART_ReBaudRate, \
	&huart1, \
}


/* Define default package */
#define E2G4_CONFIG_PACK \
{ \
	(uint8_t)E28_PACK_HEAD, \
	(uint8_t)(E28_2G4_ADDR>>8)&0xFF, \
	(uint8_t)E28_2G4_ADDR&0xFF, \
	(uint8_t)((E28_UART_INS&0x03) << 6 | (E28_UART_BAUDRATE&0x07) << 3 | (E28_RF_BPS&0x07)), \
	(uint8_t)E28_2G4_CHANNEL, \
	(uint8_t)((E28_TXMODE&0x01)<<7 | (E28_DEVICE_LEV&0x01)<<4 | (E28_LBT&0x01)<<3 | (E28_IO&0x01)<<2 | (E28_TXPOWER&0x03)) \
}


typedef struct
{
	union
	{
		uint8_t E28_SettingMessage[E28_SettingMessageLength];
		struct
		{
			uint8_t Header;
			uint8_t AddressH;
			uint8_t AddressL;
			uint8_t Sped;
			uint8_t Chan;
			uint8_t Option;
		};
	};
}E28_Setting_t;





typedef struct
{
	void(*E28_USART_IT_Register)(UART_HandleTypeDef* huartx);
	void(*E28_RF_Setting)(uint16_t Address,uint8_t Channel);
	void(*E28_USART_ReBaudRate)(uint32_t BaudRate);
	UART_HandleTypeDef* E28_Register;
}E28_Fnc;




/* Exported types ------------------------------------------------------------*/

/* Exported variables --------------------------------------------------------*/
extern E28_Fnc E28_Function;

#endif
/* End -----------------------------------------------------------------------*/
